-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make to_vec(::Integer)
an empty vector
#189
base: main
Are you sure you want to change the base?
Conversation
@@ -1,6 +1,6 @@ | |||
name = "FiniteDifferences" | |||
uuid = "26cc04aa-876d-5657-8c51-4c34ba976000" | |||
version = "0.12.18" | |||
version = "0.12.19" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be breaking instead? i think of it as a bug fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My view is treat it as a bug fix for now -- if it turns out to be super breaking and we later decide it's actually a breaking change, we can always bump the minor version number then.
@@ -67,8 +67,11 @@ function test_to_vec(x::T; check_inferred=true) where {T} | |||
return nothing | |||
end | |||
|
|||
myrandn(T::Type{<:Number}, args...) = randn(T, args...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i should probably rename this to something sensible.
robust_randn
, randn_ints_ok
, randn_that_doesnt_hate_ints
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this should have randn
in the name, since the integer method doesn't really sample from a normal distribution. Perhaps something a bit more verbose like rand_number
?
# v == [] | ||
# b(v) == 1 | ||
# which means that jvp always returns the integer itself, since [] - [] == [] | ||
_int2zero(x) = x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect that this will miss a few cases (e.g. vectors of integers), but probably that's fine for now -- we can revisit later it needs be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On a more general note: is the need for this function a manifestation of the fact that FiniteDifferences doesn't really know how to handle tangents properly?
I tackled this before leaving for holidays but didn't have time to continue when I came back. I do remember it was kind of annoying as some weird things were popping up (one symptom is the (feel free to take over) |
I think the underlying problem is related to Example 2 from this CRTU issue. Need to confirm by working through the things that are breaking though. |
I did a bit more digging into what it would take to implement this. It turns out that we're also missing a way to say "treat
Similarly, while Very doable, just requires some work. |
Closes #188
breaks a few rules in ChainRules, need to take a look at that before merging